<%@ page import="com.info.dal.UserDAL" %>
<%@ page import="com.info.model.UserInfo" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: eaglet
  Date: 2024/3/14
  Time: 8:33
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理后台</title>
    <style>
        #customers
        {
            font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
            width:100%;
            border-collapse:collapse;
        }
        #customers td, #customers th
        {
            font-size:1em;
            border:1px solid #98bf21;
            padding:3px 7px 2px 7px;
        }
        #customers th
        {
            font-size:1.1em;
            text-align:left;
            padding-top:5px;
            padding-bottom:4px;
            background-color:#A7C942;
            color:#ffffff;
        }
    </style>
</head>
<body>
    <div>你好，管理员:${UserSession.username}</div>
    <div>
        <div>用户管理</div>
        <div><a href="modityuserpass.jsp">修改密码</a> </div>
        <div>
            <%
                UserDAL userDAL = new UserDAL();
                List<UserInfo> userlist = userDAL.getAllUsers();
                //将用户列表数据放入共享变量中
                request.setAttribute("users",userlist);
            %>
            <div>
                <h2>JSTL标签方法</h2>
                <table id="customers">
                    <tr>
                        <th>用户id</th>
                        <th>用户名</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>地址</th>
                        <th>编辑</th>
                    </tr>
                    <c:forEach items="${users}" var="u">
                    <tr>
                        <td>${u.user_id}</td>
                        <td>${u.username}</td>
                        <td>${u.sex}</td>
                        <td>${u.age}</td>
                        <td>${u.address}</td>
                        <td><a href='getUserInfoByIdServlet?id=<c:out value="${u.user_id}" />' target="_blank">修改</a>
                            <a href='deleteUserByIdServlet?id=<c:out value="${u.user_id}" />' >删除</a>
                        </td>
                    </tr>
                    </c:forEach>
                </table>
            </div>
        </div>
    </div>
</body>
</html>
